﻿using Pay.Model;
using Pay.Model.Enums;
using Pay.Model.Interfaces;
using Pay.Model.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Dal
{
    public interface IPayDal
    {
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        Task<long> CreateOrder(OrderInfo model);

        /// <summary>
        /// 根据商户编号获取API信息
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<MerchantInfo> GetMerchantByCode(string code);

        /// <summary>
        /// 根据merchantId获取关联的支付宝账号
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="activeTime">激活时间大于该指定时间的账号,将被返回</param>
        /// <returns></returns>
        Task<List<AliAccountInfo>> GetAlipayAccountByMerchantId(long merchantId, bool isEnable, DateTime activeTime);

        /// <summary>
        /// 根据商家单号获取订单
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="merchantTradeNo"></param>
        /// <returns></returns>
        Task<OrderInfo> GetOrderByMerchantTradeNo(long merchantId, string merchantTradeNo);

        /// <summary>
        /// 获取订单
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="rows"></param>
        /// <param name="merchantId"></param>
        /// <param name="isCompleted"></param>
        /// <param name="payType"></param>
        /// <param name="payStatus"></param>
        /// <param name="orderAlipayAccount"></param>
        /// <param name="orderSystemAccount"></param>
        /// <param name="mchTradeNo"></param>
        /// <param name="amount"></param>
        /// <param name="amountPay"></param>
        /// <returns></returns>
        Task<IPagedOutput<OrderInfo>> GetOrders(int offset, int rows,
            long? merchantId = null, bool? isCompleted = null, PayType? payType = null, AlipayOrderStatus? payStatus = null,
            string orderAlipayAccount = null, string orderSystemAccount = null,
            string mchTradeNo = null, decimal? amount = null, decimal? amountPay = null);

        /// <summary>
        /// 获取最后一次交易信息
        /// </summary>
        /// <param name="merchantId"></param>
        /// <returns></returns>
        Task<OrderInfo> GetLastOrderByMerchantId(long merchantId);

        /// <summary>
        /// 根据支付宝账号和总金额获取二维码信息
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="alipayAccountId"></param>
        /// <param name="amount"></param>
        /// <param name="des"></param>
        /// <returns></returns>
        Task<IPagedOutput<QRCodeInfo>> GetQrcodes(int offset, int rows, long[] aliAccountId = null, decimal? amount = null, string description = null);
    }
}
